﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Utilities;

namespace DLV.Data.Entities
{
    public class PriceItemController
    {
        public int InsertPriceItem(PriceItemInfo info)
        {
            return SQL.InsertPriceItem(info.PriceItemName, info.ScheduleId, info.PriceId, info.Quantity, info.TotalPrice, info.PriceItemType, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status, info.GoDate);
        }
        public void UpdatePriceItem(PriceItemInfo info)
        {
            SQL.UpdatePriceItem(info.PriceItemId, info.PriceItemName, info.ScheduleId, info.PriceId, info.Quantity, info.TotalPrice, info.PriceItemType, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status, info.GoDate);
        }
        public void DeletePriceItem(PriceItemInfo info)
        {
            DeletePriceItem(info.PriceItemId);
        }
        public void DeletePriceItem(int priceItemId)
        {
            SQL.DeletePriceItem(priceItemId);
        }
        public PriceItemInfo GetPriceItem(int priceItemId)
        {
            return CBO.FillObject<PriceItemInfo>(SQL.GetPriceItem(priceItemId));
        }
        public List<PriceItemInfo> ListPriceItem()
        {
            return CBO.FillCollection<PriceItemInfo>(SQL.ListPriceItem());
        }
        public DataTable SelectPriceItem()
        {
            return CBO.ConvertToDataTable(ListPriceItem(), typeof(PriceItemInfo));
        }
 	    public List<PriceItemInfo> ListPriceItemBySchedule(int scheduleId, string priceItemType)
        {
            return CBO.FillCollection<PriceItemInfo>(SQL.ListPriceItemBySchedule(scheduleId, priceItemType));
        }

        public List<PriceItemInfo> ListPriceItemByIds(string priceItemIds)
        {
            return CBO.FillCollection<PriceItemInfo>(SQL.ListPriceItemByIds(priceItemIds));
        }
        public DataTable SelectPriceItemByType(int itemType)
        {
            return CBO.ConvertToDataTable(ListPriceItem().Where(p=>p.PriceItemType==itemType).ToList(), typeof(PriceItemInfo));
        }
       

        
    }
}
